//
//  CellOfCityCellOfLocalTravelNecessary.m
//  FreeTravel
//
//  Created by 徐康 on 16/9/6.
//  Copyright © 2016年 KX. All rights reserved.
//

#import "CellOfCityCellOfLocalTravelNecessary.h"
#import "FreeTravelMacro.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
@interface CellOfCityCellOfLocalTravelNecessary ()
@property (nonatomic, strong) UILabel *labelOfTitle;
@property (nonatomic, strong) UILabel *labelOfSold;
@property (nonatomic, strong) UILabel *labelOfPrice;
@property (nonatomic, strong) UIImageView *imageViewOfPhotot;
@end
@implementation CellOfCityCellOfLocalTravelNecessary
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.imageViewOfPhotot = [[UIImageView alloc]init];
        self.labelOfTitle = [[UILabel alloc]init];
        self.labelOfSold = [[UILabel alloc]init];
        self.labelOfPrice = [[UILabel alloc]init];
        [self.contentView addSubview:self.imageViewOfPhotot];
        [self.contentView addSubview:self.labelOfTitle];
        [self.contentView addSubview:self.labelOfPrice];
        
        [self.contentView addSubview:self.labelOfSold];
        
        
        
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    
    [self.imageViewOfPhotot mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.contentView);
        make.height.mas_offset(100);
            }];
    [self.labelOfTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageViewOfPhotot.mas_bottom).mas_offset(5);
        make.left.equalTo(self.contentView.mas_left).mas_offset(5);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-5);
        make.height.mas_offset(20);
    }];
    [self.labelOfSold mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.equalTo(self.contentView);
        make.top.equalTo(self.labelOfTitle.mas_bottom).mas_offset(5);
       
    }];
    self.labelOfSold.textColor = [UIColor grayColor];
    [self.labelOfPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.equalTo(self.contentView);
        make.top.equalTo(self.labelOfTitle.mas_bottom).mas_offset(5);
           }];
    self.labelOfPrice.textColor = [UIColor redColor];
    self.labelOfPrice.font = [UIFont systemFontOfSize:15];
    
}
- (void)setModel:(ModelOfLocal_basicCommendScenicSpotView *)model{
    _model = model;
    NSLog(@"%@",model.price);
    if (model.price.length > 9) {
        NSRange range = NSMakeRange(4, model.price.length-11);
        model.price = [model.price substringWithRange:range];

    }
    NSString *str = [NSString stringWithFormat:@"%@元起",model.price];
    self.labelOfSold.text = model.sold;
    self.labelOfPrice.text = str;
    self.labelOfTitle.text = model.title;
    [self.imageViewOfPhotot sd_setImageWithURL:[NSURL URLWithString:model.photo]];
}
@end
